package cn.t.keycloak.plugin.login.jpa;

import jakarta.persistence.*;

import java.util.Date;

@Entity
@Table(name = "VERIFY_PHONE_LOG")
@NamedQueries({ @NamedQuery(name=VerifyPhoneEntity.QUERY_DUPLICATE, query = "from VerifyPhoneEntity where phoneNumber = :phoneNumber and realmId = :realmId") })
public class VerifyPhoneEntity {

    public static final String QUERY_DUPLICATE = "queryDuplicate";

    public VerifyPhoneEntity() {
        // this.id = UUID.randomUUID().toString().replace("-", "");
    }

    @Id
    @Column(name = "ID")
    @GeneratedValue(strategy = GenerationType.UUID)
    private String id;

    @Column(name = "REALM_ID", nullable = false)
    private String realmId;

    @Column(name = "PHONE_NUMBER", nullable = false)
    private String phoneNumber;

    @Column(name = "USER_ID", nullable = false)
    private String userId;

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "CREATED_AT", nullable = false)
    private Date createdAt;

    @Column(name = "CONFIRMED", nullable = false)
    private int confirmed;

    @Column(name = "REGION_CODE")
    private String regionCode;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getRealmId() {
        return realmId;
    }

    public void setRealmId(String realmId) {
        this.realmId = realmId;
    }

    public String getPhoneNumber() {
        return phoneNumber;
    }

    public void setPhoneNumber(String phoneNumber) {
        this.phoneNumber = phoneNumber;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public Date getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(Date createdAt) {
        this.createdAt = createdAt;
    }

    public int getConfirmed() {
        return confirmed;
    }

    public void setConfirmed(int confirmed) {
        this.confirmed = confirmed;
    }

    public String getRegionCode() {
        return regionCode;
    }

    public void setRegionCode(String regionCode) {
        this.regionCode = regionCode;
    }
}
